package cn.tju.yanbo.commons;

import java.sql.Date;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.w3c.dom.Document;

import cn.tju.yanbo.R;
import cn.tju.yanbo.utils.AppConfig;
import cn.tju.yanbo.utils.AppUtils;
import cn.tju.yanbo.utils.LocationUtils;
import cn.tju.yanbo.weather.WeatherUtils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager;
import android.widget.AbsoluteLayout;
import android.widget.AbsoluteLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public abstract class BaseActivity extends Activity {

    public static List<Activity> APP_ACTIVITIES = new ArrayList<Activity>();
    public static Map<Object, Drawable> CACHED_PICTURES = new HashMap<Object, Drawable>();
    public static Map<Integer, Integer> VIEW_LAYOUT_MAPPING = new HashMap<Integer, Integer>();
    static {
        VIEW_LAYOUT_MAPPING.put(R.id.menu_datechoose, R.layout.choose_date);
        VIEW_LAYOUT_MAPPING.put(R.id.menu_good_occasion, R.layout.good_occasion);
        VIEW_LAYOUT_MAPPING.put(R.id.menu_homepage, R.layout.homepage);
        VIEW_LAYOUT_MAPPING.put(R.id.menu_lucky_day, R.layout.lucky_day);
        VIEW_LAYOUT_MAPPING.put(R.id.menu_lunar_calendar, R.layout.lunar_calendar);
        VIEW_LAYOUT_MAPPING.put(R.id.menu_setting, R.layout.setting);
    }
    public static int [] MENU_IDS = new int[]{R.id.menu_homepage, R.id.menu_lunar_calendar, R.id.menu_datechoose,
                                                                    R.id.menu_good_occasion, R.id.menu_lucky_day, R.id.menu_setting};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(0, 1, 1, "退出");
        return super.onCreateOptionsMenu(menu);
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Log.i("gui", "item_id="+item.getItemId());
        if(item.getItemId() == 1){
            Log.i("resources", "activity_count="+APP_ACTIVITIES.size());
            for(Activity activity : APP_ACTIVITIES) {
                activity.finish();
            }
            APP_ACTIVITIES.clear();
            
            System.exit(0);
        }
        return false;
    }
    
    protected void initTextViewFont() {
        Typeface font = AppUtils.font();
        if(font==null) {
            font = Typeface.createFromAsset(getAssets(), "fonts/a.ttf");
            AppUtils.font(font);
        }
        
        setCustomFont(R.id.menu_homepage, font);
        setCustomFont(R.id.menu_good_occasion, font);
        setCustomFont(R.id.menu_datechoose, font);
        setCustomFont(R.id.menu_lunar_calendar, font);
        setCustomFont(R.id.menu_lucky_day, font);
        setCustomFont(R.id.menu_setting, font);
        
        setCustomFont(R.id.location_view_zh, font);
        setCustomFont(R.id.location_view_en, font);
        setCustomFont(R.id.date_year, font);
        setCustomFont(R.id.date_month, font);
        setCustomFont(R.id.date_left_month_1, font);
        setCustomFont(R.id.date_left_month_2, font);
        setCustomFont(R.id.date_right_month_1, font);
        setCustomFont(R.id.date_right_month_2, font);
        setCustomFont(R.id.date_day, font);
        setCustomFont(R.id.date_left_day_1, font);
        setCustomFont(R.id.date_left_day_2, font);
        setCustomFont(R.id.date_left_day_3, font);
        setCustomFont(R.id.date_right_day_1, font);
        setCustomFont(R.id.date_right_day_2, font);
        setCustomFont(R.id.date_right_day_3, font);
        setCustomFont(R.id.date_hour, font);
        setCustomFont(R.id.date_left_hour_1, font);
        setCustomFont(R.id.date_left_hour_2, font);
        setCustomFont(R.id.date_left_hour_3, font);
        setCustomFont(R.id.date_left_hour_4, font);
        setCustomFont(R.id.date_right_hour_1, font);
        setCustomFont(R.id.date_right_hour_2, font);
        setCustomFont(R.id.date_right_hour_3, font);
        setCustomFont(R.id.date_right_hour_4, font);
    }
    
    protected void setCustomFont(int id, Typeface font) {
        View view = this.findViewById(id);
        if(view != null)  ( (TextView) view).setTypeface(font);
    }
    protected void setViewText(int id, String text) {
        TextView view = (TextView)this.findViewById(id);
        if(view != null)  {
            view.setText(text);
            
            //57,95,132
            String tag = AppUtils.toString(view.getTag());
            if(tag!=null) {
                TextPaint paint = view.getPaint();
                String [] tags = tag.split("[\\s]+");
                double radius = Double.parseDouble(AppConfig.get(tags[0]));
                double degree = Double.parseDouble(AppConfig.get(tags[1]));
//                float width = paint.measureText(text);
                float width = AppUtils.width(tag);
                if(width==-1) width = paint.measureText(text); 
                StaticLayout slayout = new StaticLayout(text, paint, (int)width+100 , Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
                int height = slayout.getHeight();

                Point centroid = this.center();
                Point position = AppUtils.position(centroid, radius, AppUtils.angle(degree), width, height);
                view.setLayoutParams(new LayoutParams((int)width, height, position.x, position.y));
                Log.i("revolve","view.x="+position.x+",view.y="+position.y+",view.width="+width+",view.height="+height);
            }
            Log.i("startup", text);
        }
    }

    protected void setCalendarView(long timeMillis) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timeMillis);
        this.setViewText(R.id.date_year, String.valueOf(calendar.get(Calendar.YEAR)));
        
        calendar.roll(Calendar.MONTH, -1);
        this.setViewText(R.id.date_left_month_2, String.valueOf(calendar.get(Calendar.MONTH)));
        calendar.roll(Calendar.MONTH, 1);
        this.setViewText(R.id.date_left_month_1, String.valueOf(calendar.get(Calendar.MONTH)));
        calendar.roll(Calendar.MONTH, 1);
        this.setViewText(R.id.date_month, String.valueOf(calendar.get(Calendar.MONTH)));
        calendar.roll(Calendar.MONTH, 1);
        this.setViewText(R.id.date_right_month_1, String.valueOf(calendar.get(Calendar.MONTH)));
        calendar.roll(Calendar.MONTH, 1);
        this.setViewText(R.id.date_right_month_2, String.valueOf(calendar.get(Calendar.MONTH)));
        
        calendar.setTimeInMillis(timeMillis);
        calendar.roll(Calendar.DAY_OF_MONTH, -3);
        this.setViewText(R.id.date_left_day_3, String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        calendar.roll(Calendar.DAY_OF_MONTH, 1);
        this.setViewText(R.id.date_left_day_2, String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        calendar.roll(Calendar.DAY_OF_MONTH, 1);
        this.setViewText(R.id.date_left_day_1, String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        calendar.roll(Calendar.DAY_OF_MONTH, 1);
        this.setViewText(R.id.date_day, String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        calendar.roll(Calendar.DAY_OF_MONTH, 1);
        this.setViewText(R.id.date_right_day_1, String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        calendar.roll(Calendar.DAY_OF_MONTH, 1);
        this.setViewText(R.id.date_right_day_2, String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        calendar.roll(Calendar.DAY_OF_MONTH, 1);
//        this.setViewText(R.id.date_right_day_3, AppUtils.format("dd", calendar.getTime()));
        this.setViewText(R.id.date_right_day_3, String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        
        calendar.setTimeInMillis(timeMillis);
        calendar.roll(Calendar.HOUR_OF_DAY, -4*2);
        this.setViewText(R.id.date_left_hour_4, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_left_hour_3, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_left_hour_2, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_left_hour_1, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_hour, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_right_hour_1, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_right_hour_2, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_right_hour_3, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
        calendar.roll(Calendar.HOUR_OF_DAY, 2);
        this.setViewText(R.id.date_right_hour_4, AppUtils.lunarHour(calendar.get(Calendar.HOUR_OF_DAY)));
    }
    
    protected void setLocationView() {
        String cityNameEn = AppConfig.get("CITY_NAME_EN");
        String cityNameZh = AppConfig.get("CITY_NAME_ZH");
        if(cityNameEn==null || cityNameZh==null) {
            cityNameEn = LocationUtils.getLocationCityName();
            cityNameZh = LocationUtils.getChineseCityName(cityNameEn);
            Log.i("gui", "location:"+cityNameEn+",cityName:"+cityNameZh);
            AppConfig.put("CITY_NAME_EN", cityNameEn);
            AppConfig.put("CITY_NAME_ZH", cityNameZh);
        } 
        
        TextView tv_zh = (TextView) this.findViewById(R.id.location_view_zh);
        TextView tv_en = (TextView) this.findViewById(R.id.location_view_en);
        tv_en.setText(cityNameEn);
        tv_zh.setText(cityNameZh);
    }
    
    protected void setWeatherView() {
        String cityWeather = AppConfig.get("CITY_WEATHER");
        if(cityWeather==null) {
            Document doc = WeatherUtils.getWeatherInfoViaGoogleApi(AppConfig.get("CITY_NAME_EN"));
            cityWeather = WeatherUtils.getWeatherFromXml(doc);
            AppConfig.put("CITY_WEATHER", cityWeather);
            Log.i("gui", "weather:"+cityWeather);
        }
        ImageView weather_iv =  (ImageView)this.findViewById(R.id.weather_view);
        weather_iv.setAlpha(10);
        weather_iv.setBackgroundDrawable(CACHED_PICTURES.get(Integer.valueOf(AppConfig.get(cityWeather))));
    }

    protected void registerIntent(int id, final Class<?> activityClass) {
        View view = this.findViewById(id);
        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
               Intent intent = new Intent();
               intent.setClass(BaseActivity.this, activityClass);
               BaseActivity.this.startActivity(intent);
            }
        });
    }
    
    protected void openWifi() {
        WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
        //自动开启wifi
        if (!wifiManager.isWifiEnabled()) {
            wifiManager.setWifiEnabled(true);
        }
    }
    
    protected boolean openGprs() {
        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

        State state = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
        if(state != NetworkInfo.State.CONNECTED) {
            Toast.makeText(this, "此应用需要连接网络，请先打开手机网络！！！", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
            return false;
        }
        return true;
    }
    
    protected void center(int viewId) {
        final View view = this.findViewById(viewId);
        
        final ViewTreeObserver observer= view.getViewTreeObserver();
        observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
             @Override
             public void onGlobalLayout() {
                 int viewidth = view.getWidth();

                 Log.i("gui", "view_width==="+viewidth);
                 
                 int screenWidth = AppUtils.SCREEN_METRICS.widthPixels;
                 int posX = (screenWidth-viewidth)/2;
//                 view.setX(posX);
//                     observer.removeGlobalOnLayoutListener(this);
             }
         });
    }
    
    public Point center(){
        return AppConfig.DATE_COMPASS_CENTROID;
    }
    public int compassRadius() {
        return AppConfig.DATE_RING_SERIES_RADIUS[2];
    }
    protected abstract void registerIntent();
    protected abstract boolean hasDateView();
    protected abstract Class<?> leftActivity();
    protected abstract Class<?> rightActivity();
    protected abstract Drawable background();
    public void update(Calendar c) {
        
    }
    public int [] getRevolveRadius() {
        return new int[]{AppConfig.DATE_RING_SERIES_RADIUS[0], AppConfig.DATE_RING_SERIES_RADIUS[1], AppConfig.DATE_RING_SERIES_RADIUS[2]};
    }

    protected void initActivity(Bundle savedInstanceState) {
        this.initTextViewFont();
        this.setCalendarView(System.currentTimeMillis());
        registerIntent();
        
        if(CACHED_PICTURES.size()==0) this.loadPictures();
        
        View view = findViewById(R.id.main_content_view);
        view.setOnTouchListener(new LayoutViewGestureListener(this));  
        view.setLongClickable(true);
        view.setBackgroundDrawable(background());
        
        APP_ACTIVITIES.add(this);
    }
    
    private void loadPictures() {
        CACHED_PICTURES.put(R.drawable.choose_date, AppUtils.createDrawable(this.getResources(), R.drawable.choose_date));
        CACHED_PICTURES.put(R.drawable.choose_date, AppUtils.createDrawable(this.getResources(), R.drawable.choose_date));
        CACHED_PICTURES.put(R.drawable.lunar_calendar, AppUtils.createDrawable(this.getResources(), R.drawable.lunar_calendar));
        CACHED_PICTURES.put(R.drawable.lucky_day, AppUtils.createDrawable(this.getResources(), R.drawable.lucky_day));
        CACHED_PICTURES.put(R.drawable.setting, AppUtils.createDrawable(this.getResources(), R.drawable.setting));
        CACHED_PICTURES.put(R.drawable.good_occasion, AppUtils.createDrawable(this.getResources(), R.drawable.good_occasion));
        CACHED_PICTURES.put(R.drawable.homepage, AppUtils.createDrawable(this.getResources(), R.drawable.homepage));
        CACHED_PICTURES.put(R.drawable.cloudy, AppUtils.createDrawable(this.getResources(), R.drawable.cloudy));
        CACHED_PICTURES.put(R.drawable.partly_cloudy, AppUtils.createDrawable(this.getResources(), R.drawable.partly_cloudy));
        CACHED_PICTURES.put(R.drawable.mostly_cloudy, CACHED_PICTURES.get(R.drawable.cloudy));
        CACHED_PICTURES.put(R.drawable.clear, AppUtils.createDrawable(this.getResources(), R.drawable.clear));
        CACHED_PICTURES.put(R.drawable.rain, AppUtils.createDrawable(this.getResources(), R.drawable.rain));
        CACHED_PICTURES.put(R.drawable.light_rain, AppUtils.createDrawable(this.getResources(), R.drawable.light_rain));
        CACHED_PICTURES.put(R.drawable.choose_botton, AppUtils.createDrawable(this.getResources(), R.drawable.choose_botton));
        CACHED_PICTURES.put(R.drawable.choose_botton_red, AppUtils.createDrawable(this.getResources(), R.drawable.choose_botton_red));
        
        //宜
        CACHED_PICTURES.put("yi_anchuang", AppUtils.createDrawable(this.getResources(), R.drawable.yi_anchuang));
        CACHED_PICTURES.put("yi_anmen", AppUtils.createDrawable(this.getResources(), R.drawable.yi_anmen));
        CACHED_PICTURES.put("yi_anzang", AppUtils.createDrawable(this.getResources(), R.drawable.yi_anzang));
        CACHED_PICTURES.put("yi_chuxing", AppUtils.createDrawable(this.getResources(), R.drawable.yi_chuxing));
        CACHED_PICTURES.put("yi_dingmeng", AppUtils.createDrawable(this.getResources(), R.drawable.yi_dingmeng));
        CACHED_PICTURES.put("yi_dongtu", AppUtils.createDrawable(this.getResources(), R.drawable.yi_dongtu));
        CACHED_PICTURES.put("yi_furen", AppUtils.createDrawable(this.getResources(), R.drawable.yi_furen));
        CACHED_PICTURES.put("yi_guabian", AppUtils.createDrawable(this.getResources(), R.drawable.yi_guabian));
        CACHED_PICTURES.put("yi_guanji", AppUtils.createDrawable(this.getResources(), R.drawable.yi_guanji));
        CACHED_PICTURES.put("yi_huaiyuan", AppUtils.createDrawable(this.getResources(), R.drawable.yi_huaiyuan));
        CACHED_PICTURES.put("yi_jiaqu", AppUtils.createDrawable(this.getResources(), R.drawable.yi_jiaqu));
        CACHED_PICTURES.put("yi_jiechu", AppUtils.createDrawable(this.getResources(), R.drawable.yi_jiechu));
        CACHED_PICTURES.put("yi_jisi", AppUtils.createDrawable(this.getResources(), R.drawable.yi_jisi));
        CACHED_PICTURES.put("yi_kaichi", AppUtils.createDrawable(this.getResources(), R.drawable.yi_kaichi));
        CACHED_PICTURES.put("yi_kaiguang", AppUtils.createDrawable(this.getResources(), R.drawable.yi_kaiguang));
        CACHED_PICTURES.put("yi_kaishi", AppUtils.createDrawable(this.getResources(), R.drawable.yi_kaishi));
        CACHED_PICTURES.put("yi_lijuan", AppUtils.createDrawable(this.getResources(), R.drawable.yi_lijuan));
        CACHED_PICTURES.put("yi_nacai", AppUtils.createDrawable(this.getResources(), R.drawable.yi_nacai));
        CACHED_PICTURES.put("yi_naqian", AppUtils.createDrawable(this.getResources(), R.drawable.yi_naqian));
        CACHED_PICTURES.put("yi_potu", AppUtils.createDrawable(this.getResources(), R.drawable.yi_potu));
        CACHED_PICTURES.put("yi_qiucai", AppUtils.createDrawable(this.getResources(), R.drawable.yi_qiucai));
        CACHED_PICTURES.put("yi_qifu", AppUtils.createDrawable(this.getResources(), R.drawable.yi_qifu));
        CACHED_PICTURES.put("yi_qiusi", AppUtils.createDrawable(this.getResources(), R.drawable.yi_qiusi));
        CACHED_PICTURES.put("yi_rulian", AppUtils.createDrawable(this.getResources(), R.drawable.yi_rulian));
        CACHED_PICTURES.put("yi_shangliang", AppUtils.createDrawable(this.getResources(), R.drawable.yi_shangliang));
        CACHED_PICTURES.put("yi_xiuzao", AppUtils.createDrawable(this.getResources(), R.drawable.yi_xiuzao));
        CACHED_PICTURES.put("yi_yanyin", AppUtils.createDrawable(this.getResources(), R.drawable.yi_yanyin));
        CACHED_PICTURES.put("yi_yixi", AppUtils.createDrawable(this.getResources(), R.drawable.yi_yixi));
        CACHED_PICTURES.put("yi_zaizhong", AppUtils.createDrawable(this.getResources(), R.drawable.yi_zaizhong));
        CACHED_PICTURES.put("yi_zhaizhan", AppUtils.createDrawable(this.getResources(), R.drawable.yi_zhaizhan));
        //small
        CACHED_PICTURES.put("yi_anchuang_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_anchuang_small));
        CACHED_PICTURES.put("yi_anmen_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_anmen_small));
        CACHED_PICTURES.put("yi_anzang_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_anzang_small));
        CACHED_PICTURES.put("yi_chuxing_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_chuxing_small));
        CACHED_PICTURES.put("yi_dingmeng_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_dingmeng_small));
        CACHED_PICTURES.put("yi_dongtu_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_dongtu_small));
        CACHED_PICTURES.put("yi_furen_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_furen_small));
        CACHED_PICTURES.put("yi_guabian_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_guabian_small));
        CACHED_PICTURES.put("yi_guanji_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_guanji_small));
        CACHED_PICTURES.put("yi_huaiyuan_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_huaiyuan_small));
        CACHED_PICTURES.put("yi_jiaqu_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_jiaqu_small));
        CACHED_PICTURES.put("yi_jiechu_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_jiechu_small));
        CACHED_PICTURES.put("yi_jisi_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_jisi_small));
        CACHED_PICTURES.put("yi_kaichi_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_kaichi_small));
        CACHED_PICTURES.put("yi_kaiguang_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_kaiguang_small));
        CACHED_PICTURES.put("yi_kaishi_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_kaishi_small));
        CACHED_PICTURES.put("yi_lijuan_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_lijuan_small));
        CACHED_PICTURES.put("yi_nacai_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_nacai_small));
        CACHED_PICTURES.put("yi_naqian_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_naqian_small));
        CACHED_PICTURES.put("yi_potu_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_potu_small));
        CACHED_PICTURES.put("yi_qiucai_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_qiucai_small));
        CACHED_PICTURES.put("yi_qifu_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_qifu_small));
        CACHED_PICTURES.put("yi_qiusi_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_qiusi_small));
        CACHED_PICTURES.put("yi_rulian_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_rulian_small));
        CACHED_PICTURES.put("yi_shangliang_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_shangliang_small));
        CACHED_PICTURES.put("yi_xiuzao_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_xiuzao_small));
        CACHED_PICTURES.put("yi_yanyin_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_yanyin_small));
        CACHED_PICTURES.put("yi_yixi_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_yixi_small));
        CACHED_PICTURES.put("yi_zaizhong_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_zaizhong_small));
        CACHED_PICTURES.put("yi_zhaizhan_small", AppUtils.createDrawable(this.getResources(), R.drawable.yi_zhaizhan_small));
        //忌
        CACHED_PICTURES.put("ji_anchuang", AppUtils.createDrawable(this.getResources(), R.drawable.ji_anchuang));
        CACHED_PICTURES.put("ji_anmen", AppUtils.createDrawable(this.getResources(), R.drawable.ji_anmen));
        CACHED_PICTURES.put("ji_anzang", AppUtils.createDrawable(this.getResources(), R.drawable.ji_anzang));
        CACHED_PICTURES.put("ji_chuxing", AppUtils.createDrawable(this.getResources(), R.drawable.ji_chuxing));
        CACHED_PICTURES.put("ji_dingmeng", AppUtils.createDrawable(this.getResources(), R.drawable.ji_dingmeng));
        CACHED_PICTURES.put("ji_dongtu", AppUtils.createDrawable(this.getResources(), R.drawable.ji_dongtu));
        CACHED_PICTURES.put("ji_furen", AppUtils.createDrawable(this.getResources(), R.drawable.ji_furen));
        CACHED_PICTURES.put("ji_guabian", AppUtils.createDrawable(this.getResources(), R.drawable.ji_guabian));
        CACHED_PICTURES.put("ji_guanji", AppUtils.createDrawable(this.getResources(), R.drawable.ji_guanji));
        CACHED_PICTURES.put("ji_huaiyuan", AppUtils.createDrawable(this.getResources(), R.drawable.ji_huaiyuan));
        CACHED_PICTURES.put("ji_jiaqu", AppUtils.createDrawable(this.getResources(), R.drawable.ji_jiaqu));
        CACHED_PICTURES.put("ji_jiechu", AppUtils.createDrawable(this.getResources(), R.drawable.ji_jiechu));
        CACHED_PICTURES.put("ji_jisi", AppUtils.createDrawable(this.getResources(), R.drawable.ji_jisi));
        CACHED_PICTURES.put("ji_kaichi", AppUtils.createDrawable(this.getResources(), R.drawable.ji_kaichi));
        CACHED_PICTURES.put("ji_kaiguang", AppUtils.createDrawable(this.getResources(), R.drawable.ji_kaiguang));
        CACHED_PICTURES.put("ji_kaishi", AppUtils.createDrawable(this.getResources(), R.drawable.ji_kaishi));
        CACHED_PICTURES.put("ji_lijuan", AppUtils.createDrawable(this.getResources(), R.drawable.ji_lijuan));
        CACHED_PICTURES.put("ji_nacai", AppUtils.createDrawable(this.getResources(), R.drawable.ji_nacai));
        CACHED_PICTURES.put("ji_naqian", AppUtils.createDrawable(this.getResources(), R.drawable.ji_naqian));
        CACHED_PICTURES.put("ji_potu", AppUtils.createDrawable(this.getResources(), R.drawable.ji_potu));
        CACHED_PICTURES.put("ji_qifu", AppUtils.createDrawable(this.getResources(), R.drawable.ji_qifu));
        CACHED_PICTURES.put("ji_qiucai", AppUtils.createDrawable(this.getResources(), R.drawable.ji_qiucai));
        CACHED_PICTURES.put("ji_qiusi", AppUtils.createDrawable(this.getResources(), R.drawable.ji_qiusi));
        CACHED_PICTURES.put("ji_rulian", AppUtils.createDrawable(this.getResources(), R.drawable.ji_rulian));
        CACHED_PICTURES.put("ji_shangliang", AppUtils.createDrawable(this.getResources(), R.drawable.ji_shangliang));
        CACHED_PICTURES.put("ji_xiuzao", AppUtils.createDrawable(this.getResources(), R.drawable.ji_xiuzao));
        CACHED_PICTURES.put("ji_yanyin", AppUtils.createDrawable(this.getResources(), R.drawable.ji_yanyin));
        CACHED_PICTURES.put("ji_yixi", AppUtils.createDrawable(this.getResources(), R.drawable.ji_yixi));
        CACHED_PICTURES.put("ji_zaizhong", AppUtils.createDrawable(this.getResources(), R.drawable.ji_zaizhong));
        CACHED_PICTURES.put("ji_zhaizhan", AppUtils.createDrawable(this.getResources(), R.drawable.ji_zhaizhan));
        //small 
        CACHED_PICTURES.put("ji_anchuang_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_anchuang_small));
        CACHED_PICTURES.put("ji_anmen_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_anmen_small));
        CACHED_PICTURES.put("ji_anzang_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_anzang_small));
        CACHED_PICTURES.put("ji_chuxing_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_chuxing_small));
        CACHED_PICTURES.put("ji_dingmeng_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_dingmeng_small));
        CACHED_PICTURES.put("ji_dongtu_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_dongtu_small));
        CACHED_PICTURES.put("ji_furen_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_furen_small));
        CACHED_PICTURES.put("ji_guabian_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_guabian_small));
        CACHED_PICTURES.put("ji_guanji_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_guanji_small));
        CACHED_PICTURES.put("ji_huaiyuan_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_huaiyuan_small));
        CACHED_PICTURES.put("ji_jiaqu_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_jiaqu_small));
        CACHED_PICTURES.put("ji_jiechu_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_jiechu_small));
        CACHED_PICTURES.put("ji_jisi_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_jisi_small));
        CACHED_PICTURES.put("ji_kaichi_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_kaichi_small));
        CACHED_PICTURES.put("ji_kaiguang_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_kaiguang_small));
        CACHED_PICTURES.put("ji_kaishi_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_kaishi_small));
        CACHED_PICTURES.put("ji_lijuan_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_lijuan_small));
        CACHED_PICTURES.put("ji_nacai_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_nacai_small));
        CACHED_PICTURES.put("ji_naqian_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_naqian_small));
        CACHED_PICTURES.put("ji_potu_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_potu_small));
        CACHED_PICTURES.put("ji_qifu_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_qifu_small));
        CACHED_PICTURES.put("ji_qiucai_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_qiucai_small));
        CACHED_PICTURES.put("ji_qiusi_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_qiusi_small));
        CACHED_PICTURES.put("ji_rulian_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_rulian_small));
        CACHED_PICTURES.put("ji_shangliang_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_shangliang_small));
        CACHED_PICTURES.put("ji_xiuzao_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_xiuzao_small));
        CACHED_PICTURES.put("ji_yanyin_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_yanyin_small));
        CACHED_PICTURES.put("ji_yixi_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_yixi_small));
        CACHED_PICTURES.put("ji_zaizhong_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_zaizhong_small));
        CACHED_PICTURES.put("ji_zhaizhan_small", AppUtils.createDrawable(this.getResources(), R.drawable.ji_zhaizhan_small));
    }
}
